import request from "@/utils/request";
//角色相关的接口

//获取按条件查询分页角色列表
export const queryRoles = (data) => {
  return request({
    method: "POST",
    url: "/boss/role/getRolePages",
    data,
  });
};

//获取指定id的角色信息
export const getRole = (id) => {
  return request({
    method: "GET",
    url: `/boss/role/${id}`,
  });
};

//保存或更新角色信息
export const saveOrUpdata = (data) => {
  return request({
    method: "POST",
    url: "/boss/role/saveOrUpdate",
    data,
  });
};

//删除指定id的角色
export const deleteRole = (roleId) => {
  return request({
    method: "DELETE",
    url: `/boss/role/${roleId}`,
  });
};

//获取角色所拥有的菜单信息
export const getRoleMenus = (roleId) => {
  return request({
    method: "GET",
    url: "/boss/menu/getRoleMenus",
    params: {
      roleId,
    },
  });
};

//给角色分配对应的菜单项
export const setRoleMenus = (data) => {
  return request({
    method: "POST",
    url: "/boss/menu/allocateRoleMenus",
    data,
  });
};

//获取角色拥有的资源信息
export const getRoleResources = (roleId) => {
  return request({
    method: "GET",
    url: "/boss/resource/getRoleResources",
    params: {
      roleId,
    },
  });
};

//设置角色拥有的资源信息
export const setRoleResources = (data = {}) => {
  return request({
    method: "POST",
    url: "/boss/resource/allocateRoleResources",
    data,
  });
};
